#include <REGX52.H>
#include "Timer0.H"
#include "Key.H"
#include "Delay.H"
#include <INTRINS.H>

unsigned char TimerMod;
unsigned char KeyNum,i;
void main()//主函数
{
	P2=0xFE;

	Timer0_Init();		//1毫秒@12.000MHz
	while(1)
	{
		KeyNum=Key();
		if(KeyNum)
		{
			
			if(KeyNum==1)
			{
			TimerMod++;	
			}
			if(KeyNum>=2)
			{
				TimerMod=0;
				
			}
			
		}
	}
}
void Timer0_Routine() interrupt 1 //中断函数
{	
	static unsigned int Timecount;//中断变量,static 静态变量。
	TL0 = 0x18;		//设置定时初值
	TH0 = 0xFC;		//设置定时初值
	Timecount++;//时间每1ms自增1

	if(Timecount>=500)//计时器1s后归零
	{
		Timecount=0;//计时器清零
		if(TimerMod==0)
		{
		P2=_crol_(P2,1);	//LED输出

		}
		if(TimerMod==1)
		{
		P2=_cror_(P2,1);	//LED输出

		}

	}	

	
}
